public class questiion_35 {
}
//关于折半查找的题，使用log n的时间复杂度
class Solution_35 {
    public int searchInsert(int[] nums, int target) {
        if(nums==null||nums.length==0)
            return 0;//返回索引0
        int center,l=0,r=nums.length-1;
        while(true){
            center=(l+r)/2;
            if(target==nums[center])
                return center;
            if(l>=r){
                return target>nums[l]?l+1:l;
            }
            if(target>nums[center]){
                l=center+1;
            }
            if(target<nums[center]){
                r=center-1;
            }
        }
    }
}
